package com.itheima.Demo01.demo05S;

import java.util.concurrent.Callable;

public class MyCallable05S implements Callable<String> {
    private  int count = 100;
    private  Object obj = new Object();

    @Override
    public String call() throws Exception {
        while (true) {
            synchronized (obj) {
                if (count == 0) {
//                System.out.println("票卖完了");
                    break;
                } else {
                    count--;
                    System.out.println(Thread.currentThread().getName() + "在卖票,还剩下" + count);
                }
            }
        }
        return "卖完了";
    }
}
